'''
Created on 2012/07/03

@author: harendra
'''
from basehandler.BaseHandler import BaseHandler
from pythonutils.instapaperlib import Instapaper
from FeedHandler.FeedHandler import FeedListGetter
import logging

import json
class InstaPassChecker(BaseHandler):
    def get(self):
        requestData=self.request.GET
        username=requestData['username']
        password=requestData['password']
        f=Instapaper(username,password,False)
        instaresponse=f.auth()
        logging.error(instaresponse)
        if instaresponse[0]==200:
            feedlist=FeedListGetter().getFeeds(username, password)
            logging.error(feedlist)
            return self.response.write(json.dumps(feedlist))
        elif instaresponse[0]==403:
            return self.response.write(json.dumps({'result':'failed'}))
        else:
            return self.response.write(json.dumps({'result':'failed'}))
        